package com.deyuanyun.pic.settings.service.greatwall.impl;

import com.deyuanyun.pic.settings.domain.greatwall.ProductLogTempExample;
import com.deyuanyun.pic.settings.domain.greatwall.ProductLogTempExpand;
import com.deyuanyun.pic.settings.domain.greatwall.ProductLogTempWithBLOBs;
import com.deyuanyun.pic.settings.mapper.greatwall.ProductLogTempExpandMapper;
import com.deyuanyun.pic.settings.mapper.greatwall.ProductLogTempMapper;
import com.deyuanyun.pic.settings.service.greatwall.ProductLogTempService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  产品日志暂存service实现类
 *  @author axiao(xj08.dream@gmail.com)
 *  @date 2016-12-20
 *  @version 1.0
 *  Histroy: [修改人][时间][描述]
 */
@Service
public class ProductLogTempServiceImpl implements ProductLogTempService {

    @Autowired
    private ProductLogTempMapper productLogTempMapper;

    @Autowired
    private ProductLogTempExpandMapper productLogTempExpandMapper;

    @Override
    public int insertSelective(ProductLogTempWithBLOBs record) {
        return productLogTempMapper.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(ProductLogTempWithBLOBs record) {
        return productLogTempMapper.updateByPrimaryKeyWithBLOBs(record);
    }

    @Override
    public Page<ProductLogTempExpand> queryUntreatedLogs(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return productLogTempExpandMapper.queryUntreatedLogs();
    }

    @Override
    public int updateHandleByIds(List<String> ids) {
        ProductLogTempWithBLOBs withBLOBs = new ProductLogTempExpand();
        withBLOBs.setHandled((short) 1);
        ProductLogTempExample example = new ProductLogTempExample();
        example.createCriteria().andDeletedNotEqualTo((short) 0).andIdIn(ids);
        productLogTempMapper.updateByExampleSelective(withBLOBs, example);
        return 0;
    }
}
